import { View } from "../../../mvc/core/View";
import { ILayOut } from "../../../../modules/interfaces/ILayOut";
import { IClean } from "../../../../com/gengine/core/IClean";
import { LayerManager } from "../../manager/LayerManager";
import { Global } from "../../../../com/gengine/global/Global";
import { ObjCreate } from "../common/ObjCreate";
import { SecTimer } from "../../../../com/gengine/core/frame/SecTimer";
import { GTextFormat } from "../../../common/GTextFormat";
import { FontUtil } from "../../../common/font/FontUtil";
import { GlobalStyle } from "../../../common/global/GlobalStyle";
import { Language } from "../../../../extend/language/Language";
import { EArenaMode } from "../../../../Message/Public/EArenaMode";
import { TimerType } from "../../../../com/gengine/core/frame/TimerType";
//class ArenaWaitingTimeView
    
    export  class ArenaWaitingTimeView extends View implements ILayOut, IClean
    {
        constructor()
        {
            super();
            layer = LayerManager.msgTipLayer;
            this.x = (Global.stage.stageWidth - 300) / 2;
            this.y = 90;
            this.mouseEnabled = false;
            this.mouseChildren = false;
            this.init();
            return;
        }

        /* internal  */init(): void
        {
            ObjCreate.createBg(0, 0, 300, 105, this, "ToolTipBg");
            this._secTimer = new SecTimer();
            var loc1=new GTextFormat(FontUtil.songtiName, 12, 15788607);
            loc1.bold = true;
            var loc2=GlobalStyle.textFormatGreen;
            loc2.leading = 7;
            this._tfWait = ObjCreate.createTextField("", 30, 15, 270, 22, this, loc1);
            this._tfWait.htmlText = Language.getStringByParam(42251, "0");
            this._tfMode = ObjCreate.createTextField("", 30, 35, 270, 20, this, GlobalStyle.textFormat1);
            this._tfModeTips = ObjCreate.createTextField("", 30, 55, 270, 40, this, loc2);
            this._tfModeTips.multiline = true;
            this._tfModeTips.wordWrap = true;
            return;
        }

        public updateMode(arg1: EArenaMode): void
        {
            if (arg1.value() == EArenaMode._EArenaOneVsOne) 
            {
                this._tfMode.htmlText = Language.getString(42284);
                this._tfModeTips.htmlText = Language.getString(42285);
            }
            if (arg1.value() == EArenaMode._EArenaOneVsThree) 
            {
                this._tfMode.htmlText = Language.getString(42286);
                this._tfModeTips.htmlText = Language.getString(42287);
            }
            return;
        }

        public start(): void
        {
            this._secTimer.start();
            this._secTimer.addListener(TimerType.ENTERFRAME, this.onTimeChange);
            return;
        }

        /* internal  */onTimeChange(arg1: SecTimer): void
        {
            this._tfWait.htmlText = Language.getStringByParam(42251, this._secTimer.currentCount.toString());
            return;
        }

        public /* override */ hide(): void
        {
            super.hide();
            this._tfWait.htmlText = Language.getStringByParam(42251, "0");
            return;
        }

        public reset(): void
        {
            this._secTimer.reset();
            return;
        }

        public stop(): void
        {
            this._secTimer.stop();
            return;
        }

        public resetPosition(): void
        {
            this.x = (Global.stage.stageWidth - 300) / 2;
            this.y = 90;
            return;
        }

        public clean(): void
        {
            this._secTimer.dispose(false);
            if (this.parent) 
            {
                this.parent.removeChild(this);
            }
            return;
        }

        /* internal */ /* var */_secTimer: SecTimer;

        /* internal */ /* var */_tfWait: Object /* flash.text.TextField */;

        /* internal */ /* var */_tfMode: Object /* flash.text.TextField */;

        /* internal */ /* var */_tfModeTips: Object /* flash.text.TextField */;
    }
